<template>
  <a-card :bordered="false">
    <a-tabs v-model="activeKey">
      <a-tab-pane
        v-if="hasPermission('LoginLog')"
        key="0"
      >
         <span slot="tab">
			<a-icon type="login" />
      	 登录日志
        </span>
        <LoginLog ref="loginLog" v-if="activeKey === '0'" />
      </a-tab-pane>
      <a-tab-pane
        v-if="hasPermission('RunLog')"
        key="1"
      >
      <span slot="tab">
			<a-icon type="play-circle" />
      	 运行日志
        </span>
        <RunLog ref="runLog" v-if="activeKey === '1'" />
      </a-tab-pane>
      <a-tab-pane
        v-if="hasPermission('ActionLog')"
        key="2"
      >
      <span slot="tab">
			<a-icon type="info-circle" />
      	 操作日志
        </span>
        <ActionLog ref="actionLog" v-if="activeKey === '2'" />
      </a-tab-pane>
      <a-tab-pane
        v-if="hasPermission('ErrorLog')"
        key="3"
      >
      <span slot="tab">
			<a-icon type="close-circle" />
      	错误日志
        </span>
        <ErrorLog ref="errorLog" v-if="activeKey === '3'" />
      </a-tab-pane>
      <a-tab-pane
        v-if="hasPermission('DeBuggerLog')"
        key="4"
      >
      <span slot="tab">
			<a-icon type="exclamation-circle" />
      	 调试日志
        </span>
        <DeBuggerLog ref="deBuggerLog" v-if="activeKey === '4'" />
      </a-tab-pane>
      <a-tab-pane
        v-if="hasPermission('AlarmLog')"
        key="5"
      >
      <span slot="tab">
			<a-icon type="warning" />
      	 告警日志
        </span>
        <AlarmLog ref="alarmLog" v-if="activeKey === '5'" />
      </a-tab-pane>
    </a-tabs>
  </a-card>
</template>

<script>
  import ActionLog from './modules/ActionLog'
  import AlarmLog from './modules/AlarmLog'
  import DeBuggerLog from './modules/DeBuggerLog'
  import ErrorLog from './modules/ErrorLog'
  import LoginLog from './modules/LoginLog'
  import RunLog from './modules/RunLog'
  import { hasRight } from "@/utils/util"

  export default {
    name: 'F0502',
    // logType
    // 日志类型（0操作日志，1登录日志，2定时日志，3调试日志，4错误日志，5告警日志，6运行日志）
    // operateType
    // 操作类型（1查询，2添加，3修改，4删除,5导入,6导出,7运行,8调用,9越权,10审计查询,11配置,12备份,13恢复,14启动，15停止）
    components: { ActionLog, AlarmLog, DeBuggerLog, ErrorLog, LoginLog, RunLog },
    data() {
      return {
        activeKey: '0',
      }
    },
    methods: {
      hasPermission(code) {
        return hasRight(code);
      },
      handleTabChange() {
        let key = this.activeKey;
        if (key === '0' && this.$refs.loginLog) {
          this.$refs.loginLog.loadData();
        } else if (key === '1' && this.$refs.runLog) {
          this.$refs.runLog.loadData();
        } else if (key === '2' && this.$refs.actionLog) {
          this.$refs.actionLog.loadData();
        } else if (key === '3' && this.$refs.errorLog) {
          this.$refs.errorLog.loadData();
        } else if (key === '4' && this.$refs.deBuggerLog) {
          this.$refs.deBuggerLog.loadData();
        } else if (key === '5' && this.$refs.alarmLog) {
          this.$refs.alarmLog.loadData();
        }
      },
    }
  }
</script>
<style lang="less" scoped>
@import '~@assets/less/search.less';
</style>